import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../../view/FieldFile.dart';
import '../../view/file_picker_widget.dart';


class TestFilePickerWidgetPage extends StatefulWidget {
  const TestFilePickerWidgetPage({Key? key}) : super(key: key);

  @override
  _TestFilePickerWidgetPageState createState() => _TestFilePickerWidgetPageState();
}

class _TestFilePickerWidgetPageState extends State<TestFilePickerWidgetPage> {
  final FilePickerController _controller = FilePickerController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("测试上传文件组件页面"),
        ),
        body:Column(
          children: [ Container(
              color: Colors.white,
              width: double.infinity,
              height: 300,
              child: FieldFile(
                listData: [],
                filePickerController : _controller,
                label: "测试文件",

                readOnly: false,
                initialValue: [],
                showLine: true,
                onSaved: (value) {
                  print("onSaved${value}");
                },
                onChanged: (value) {
                  print("onChanged${value}");
                },
              )
          ),
            Container(
              width: double.infinity,
              height: 48,
              margin: EdgeInsets.all(16),
              child: MaterialButton(
                color: Colors.greenAccent,
                onPressed: () {
                  print(_controller.data);
                },
                child: Text("添加"),
              ),
            )
          ],
        )
       );
  }
}
